package com.whm.hrmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.whm.hrmanagement.domain.vo.OaSalaryVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.whm.common.annotation.Log;
import com.whm.common.core.controller.BaseController;
import com.whm.common.core.domain.AjaxResult;
import com.whm.common.enums.BusinessType;
import com.whm.hrmanagement.domain.OaSocCity;
import com.whm.hrmanagement.service.IOaSocCityService;
import com.whm.common.utils.poi.ExcelUtil;
import com.whm.common.core.page.TableDataInfo;

/**
 * 参保城市Controller
 * 
 * @author whm
 * @date 2024-02-09
 */
@RestController
@RequestMapping("/hrmanagement/city")
public class OaSocCityController extends BaseController
{
    @Autowired
    private IOaSocCityService oaSocCityService;

    /**
     * 查询参保城市列表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:city:list')")
    @GetMapping("/list")
    public TableDataInfo list(OaSocCity oaSocCity)
    {
        startPage();
        List<OaSocCity> list = oaSocCityService.selectOaSocCityList(oaSocCity);
        return getDataTable(list);
    }

    /**
     * 查询所有城市列表
     */

    @GetMapping("/allgetCity")
    public AjaxResult allgetCity( )
    {
        return success(oaSocCityService.allgetCity());
    }

    /**
     * 导出参保城市列表
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:city:export')")
    @Log(title = "参保城市", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OaSocCity oaSocCity)
    {
        List<OaSocCity> list = oaSocCityService.selectOaSocCityList(oaSocCity);
        ExcelUtil<OaSocCity> util = new ExcelUtil<OaSocCity>(OaSocCity.class);
        util.exportExcel(response, list, "参保城市数据");
    }

    /**
     * 获取参保城市详细信息
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:city:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(oaSocCityService.selectOaSocCityById(id));
    }

    /**
     * 新增参保城市
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:city:add')")
    @Log(title = "参保城市", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OaSocCity oaSocCity)
    {
        return toAjax(oaSocCityService.insertOaSocCity(oaSocCity));
    }

    /**
     * 修改参保城市
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:city:edit')")
    @Log(title = "参保城市", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OaSocCity oaSocCity)
    {
        return toAjax(oaSocCityService.updateOaSocCity(oaSocCity));
    }

    /**
     * 删除参保城市
     */
    @PreAuthorize("@ss.hasPermi('hrmanagement:city:remove')")
    @Log(title = "参保城市", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(oaSocCityService.deleteOaSocCityByIds(ids));
    }
}
